// https://leetcode.cn/problems/is-subsequence/?envType=study-plan-v2&envId=top-interview-150

class Solution {
public:
    bool isSubsequence(string s, string t) {
        int n = t.size(), m = s.size();
        int i = 0, j = 0;

        while (i < n && j < m) {
            if (t[i] == s[j]) j++;
            i++;
        }
        return j == m;
    }
};